package cn.com.qingz.modules.user.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

/**
 * 角色 (角色和资源 多对多的关系)
 * @author jiulong.hu
 */
@Table(name = "sys_role")
public class Role implements Serializable {
    private static final long serialVersionUID = -6389240132405845327L;

    @Id
    @Column(name = "id")
    private Integer id;

    @NotNull(message = "角色代码不能为空")
    private String role; //角色标识 程序中判断使用 ,如"admin" 唯一

    @NotNull(message = "角色名不能为空")
    private String description; //角色描述,UI界面显示使用

    @NotNull(message = "权限不能为空")
    private String resource_ids; //资源(权限)id 多对多

    private String status = "N";

    public Role() {}

    public Role(String role, String description) {
        this.role = role;
        this.description = description;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getResource_ids() {
        return resource_ids;
    }

    public void setResource_ids(String resource_ids) {
        this.resource_ids = resource_ids;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null || getClass() != o.getClass())
            return false;

        Role role = (Role) o;

        if (id != null ? !id.equals(role.id) : role.id != null)
            return false;

        return true;
    }

    public int hashCode() {
        return id != null ? id.hashCode() : 0;
    }

}
